//
//  GCMMyNoticeHttpRequst.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/11.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMMyNoticeHttpRequst.h"
#import "GCMNoticeListModel.h"

@implementation GCMMyNoticeHttpRequst

+ (NSURLSessionDataTask *)postDataWithUserName:(NSString *)username WithDepart:(NSString *)departId WithPage:(NSString *)page Success:(void (^) (id obj,id noticeModel , NSError *))success {
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"username"] = username;
    parameters[@"departId"] = departId;
    parameters[@"page"] = page;
    
    
    return [[CZHAppNetAPIClient sharedClient] POST:NOTICELIST_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"html1+  %@",responseObject);
        NSMutableArray *NoticeListArray = [[NSMutableArray alloc]init];
        NSMutableArray *noticeListArray = [[NSMutableArray alloc]init];
        noticeListArray = [dict objectForKey:@"data"];
        for (NSDictionary *dict1 in noticeListArray) {
            GCMNoticeListModel *listModel = [[GCMNoticeListModel alloc]initWithDictionary:dict1 error:nil];
            listModel.idd = [dict1 valueForKey:@"id"];
        //    NSLog(@"%@",listModel);
            [NoticeListArray addObject:listModel];
         //   NSLog(@"---%@",NoticeListArray);
        }
        
        if (success) {
            success(nil,NoticeListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"++2+  %@",error);
        if (success) {
            success(nil,nil, error);
        }
    }];
}
+ (NSURLSessionDataTask *)postDataWithUserName:(NSString *)username WithRealName:(NSString *)realName WithId:(NSString *)idd Success:(void (^) (id obj , NSError *))success {
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"username"] = username;
    parameters[@"realName"] = realName;
    parameters[@"id"] = idd;
    
    
    return [[CZHAppNetAPIClient sharedClient] POST:NOTICEDETAIL_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        //NSLog(@"++1+  %@",dict);
        NSMutableDictionary *noticeListDic = [[NSMutableDictionary alloc]init];
        noticeListDic = [dict objectForKey:@"data"];
        if (success) {
            success(noticeListDic,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
}

@end
